// 蜂鸣器控制模块
module buzzer_control (
    input                   clk,
    input                   rst_n,
    input                   key_value,
    input                   key_flag,
    output reg              buzzer
);

    always @(posedge clk or negedge rst_n) begin
        if(!rst_n) buzzer <= 0;
        else if(key_flag && (~key_value)) buzzer <= ~buzzer;
        else buzzer <= buzzer;
    end

endmodule  //buzzer_control